package main

import (
	"fmt"
	"unsafe"
)

type X struct {
	a bool
	b int16
	c []int
}

func main() {
	var x = X{
		true,
		1,
		[]int{1, 2, 3},
	}
	fmt.Println(unsafe.Sizeof(x))   // 32
	fmt.Println(unsafe.Sizeof(x.a)) // 1
	fmt.Println(unsafe.Sizeof(x.b)) // 2
	fmt.Println(unsafe.Sizeof(x.c)) // 24
	fmt.Println("alignof")
	fmt.Println(unsafe.Alignof(x.a)) // 1
	fmt.Println(unsafe.Alignof(x.b)) // 2
	fmt.Println(unsafe.Alignof(x.c)) // 8
	fmt.Println("offsetof")
	fmt.Println(unsafe.Offsetof(x.a)) // 0
	fmt.Println(unsafe.Offsetof(x.b)) // 2
	fmt.Println(unsafe.Offsetof(x.c)) // 8
}
